package cn.iocoder.yudao.framework.common.enums.pay;

import cn.hutool.core.util.ArrayUtil;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * @author FFFF
 */

@Getter
@AllArgsConstructor
public enum PayCollectTypeEnum implements ArrayValuable<Integer> {

    BANK(0, "银行卡"),
    ALI_PAY(10, "支付宝"),
    WX_PAY(20, "微信"),
    ;

    public static final Integer[] ARRAYS = Arrays.stream(values()).map(PayCollectTypeEnum::getType).toArray(Integer[]::new);

    private final Integer type;
    private final String name;

    @Override
    public Integer[] array() {
        return ARRAYS;
    }

    public static PayCollectTypeEnum valueOf(Integer status) {
        if (status == null) {
            return null;
        }
        return ArrayUtil.firstMatch(item -> item.getType().equals(status), values());
    }
}
